package com.web.cms.ad.service;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.cms.ad.dao.AdvDao;
import com.web.cms.ad.model.Adv;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 广告业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2017年11月13日
 */
@Service("adAdvService")
@Transactional
@JdbcDataSource(Const.DS_CMS)
public class AdvService
{
	@Autowired
	private AdvDao advDao;
	
	public AdvService()
	{
	}
	
	public Adv save(Adv adv)
	{
		if (adv.getId() == null)
		{
			advDao.save(adv);
		}
		else
		{
			advDao.update(adv);
		}
		Adv a = advDao.get(adv.getId());
		return a;
	}
	
	public Adv get(Integer id)
	{
		Adv adv = advDao.getSelect(id);
		return adv;
	}

	public Adv getSelect(Integer id)
	{
		return advDao.getSelect(id);
	}
	
	public Page<Adv> list(Adv adv, Page<Adv> page)
	{
		page = advDao.list(adv, page);
		return page;
	}
	
	public List<Adv> list(Adv adv)
	{
		List<Adv> list = advDao.list(adv);
		return list;
	}
	
	public void delete(Adv adv)
	{
		advDao.delete(adv);
	}
	
}
